/**
 * \file Mutex.h
 * \brief Mutex definition class
 * \author Edouard ROGE
 * \date 01 September 2012
 */

#ifndef _MUTEX_WIN32_
#define _MUTEX_WIN32_

#include <Windows.h>
#include "Core/Error/Error.h"

namespace Core
{
	namespace Thread
	{
		/**
		 * \class Mutex
		 * \brief Needed when several Threads need to write in the same object to avoid conflicts
		 * @see Thread
		 */
		class Mutex
		{
		public:
			/**
			 * \fn Mutex();
			 * \brief Default constructor
			 */
			Mutex();

			/**
			 * \fn virtual ~Mutex();
			 * \brief Destructor
			 */
			virtual ~Mutex();

			/**
			 * \fn error Lock();
			 * \return Returns if the mutex is correctly locked
			 * \brief Lock the mutex to keep the right of writing
			 */
			error Lock();

			/**
			 * \fn error Unlock();
			 * \return Returns if the mutex is correctly released
			 * \brief Release the mutex to allow other tasks to write
			 */
			error Unlock();

		private:

			/** the mutex */
			HANDLE m_Mutex;
		};
	}
}

#endif // _MUTEX_WIN32_
